
import { ApiProperty } from '@nestjs/swagger';
import { modelOptions, prop } from '@typegoose/typegoose';
import { IsNotEmpty, IsOptional, Allow } from 'class-validator';

// 自动为每个属性添加时间戳
@modelOptions({
  schemaOptions: {
    timestamps: true,
  },
})
// 数据库中自动生成 handpicdevice 集合
export class HandpicDevice {

  @ApiProperty({ description: '设备名称' })
  @IsNotEmpty({ message: '设备名称不能为空' })
  @prop()
  deviceName: string;

  @ApiProperty({ description: '设备描述' })
  @IsNotEmpty({ message: '设备描述不能为空' })
  @prop()
  deviceDesc: string;

  @ApiProperty({ description: '设备特点' })
  @IsNotEmpty({ message: '设备特点不能为空' })
  @prop()
  deviceCharact: any[];

  @ApiProperty({ description: '展示排序' })
  @IsNotEmpty({ message: '展示排序不能为空' })
  @prop()
  order: number;

  @ApiProperty({ description: '设备照片' })
  @IsNotEmpty({ message: '设备照片不能为空' })
  @prop()
  imgUrl: string;

  @ApiProperty({ description: '链接类型' })
  @IsNotEmpty({ message: '链接类型不能为空' })
  @prop()
  linkType: string;

  @ApiProperty({ description: '链接地址' })
  @IsNotEmpty({ message: '链接地址不能为空' })
  @prop()
  toLink: string;

  @ApiProperty({ description: '链接地址描述' })
  @IsOptional()
  @prop()
  toLinkDesc: string;

  @Allow()
  _id: string;

  @Allow()
  createdAt: string;

  @Allow()
  updatedAt: string;

  @Allow()
  __v: string;
}
